home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / modelers / geomview / source.lha / Geomview / src / lib / gprim / comment / commentcreate.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-16  |  2.3 KB  |  90 lines

  1. /* Copyright (c) 1992 The Geometry Center; University of Minnesota
  2.    1300 South Second Street;  Minneapolis, MN  55454, USA;
  3.    
  4. This file is part of geomview/OOGL. geomview/OOGL is free software;
  5. you can redistribute it and/or modify it only under the terms given in
  6. the file COPYING, which you should have received along with this file.
  7. This and other related software may be obtained via anonymous ftp from
  8. geom.umn.edu; email: software@geom.umn.edu. */
  9. static char *copyright = "Copyright (C) 1992 The Geometry Center";
  10.  
  11. /*
  12.  * Authors: Charlie Gunn, Stuart Levy, Tamara Munzner, Mark Phillips,
  13.  * Nathaniel Thurston
  14.  */
  15.  
  16. /*
  17.  * Comment creation, editing, retrieval and deletion.
  18.  */
  19.  
  20. #include "commentP.h"
  21. #include "transobj.h"
  22.  
  23. void
  24. CommentDelete( comment )
  25.     Comment *comment;
  26. {
  27.     if( comment ) {
  28.     if (comment->name) OOGLFree(comment->name);
  29.     if (comment->type) OOGLFree(comment->type);
  30.     if (comment->data) OOGLFree(comment->data);
  31.     }
  32. }
  33.  
  34. Comment *
  35. CommentCopy( Comment *comment ) 
  36. {
  37.   register Comment *nc;
  38.   int datalength = comment->length;
  39.  
  40.   if (datalength == 0) datalength = strlen(comment->data)+1;
  41.   nc = OOGLNewE(Comment, "CommentCopy: Comment");
  42.   GGeomInit(nc, comment->Class, comment->magic, NULL);
  43.   nc->name = OOGLNewNE(char, strlen(comment->name)+1, "Comment name");
  44.   nc->type = OOGLNewNE(char, strlen(comment->type)+1, "Comment type");
  45.   nc->data = OOGLNewNE(char, datalength, "Comment data");
  46.   strcpy(nc->name, comment->name);
  47.   strcpy(nc->type, comment->type);
  48.   nc->length = comment->length;
  49.   strcpy(nc->data, comment->data);
  50.   return(nc);
  51. }
  52.  
  53. Comment *
  54. CommentCreate ( Comment *exist, GeomClass *classp, va_list a_list )
  55. {
  56.     register Comment *comment;
  57.     int attr;
  58.     int fourd = 0;
  59.     int copy = 1;
  60.     float *f;
  61.     Transform *t;
  62.     Geom *g;
  63.     Handle *h;
  64.  
  65.     if (exist == NULL) {
  66.     comment = OOGLNewE(Comment, "CommentCreate comment");
  67.     GGeomInit (comment, classp, COMMENTMAGIC, NULL);
  68.     comment->name = NULL;
  69.     comment->type = NULL;
  70.     comment->length = 0;
  71.     comment->data = NULL;
  72.     } else {
  73.     /* Check that exist is an comment. */
  74.     comment = exist;
  75.     }
  76.  
  77.     while (attr = va_arg (a_list, int)) {
  78.     switch(attr) {
  79.     default:
  80.         if(GeomDecorate(comment, ©, attr, &a_list)) {
  81.         OOGLError (0, "CommentCreate: Undefined option: %d", attr);
  82.         if(exist == NULL) GeomDelete ((Geom *)comment);
  83.         return NULL;
  84.         }
  85.     }
  86.     }
  87.  
  88.     return comment;
  89. }
  90.